<template>
  <div
    :style="{
      '--scroll-width': '0px',
    }"
  >
    <div class="home-header">
      <ly-header />
    </div>
    <div class="wrap-item">
      <div class="wrap-btn-group">
        <span class="wrap-btn wrap-go-back" @click="go">返回</span>
      </div>
      <div class="wrap-other-roll">
        <el-descriptions :column="1" border>
          <el-descriptions-item label="标题">
            {{ lockData.title }}
          </el-descriptions-item>
          <el-descriptions-item label="发布人">
            {{ lockData.addName }}
          </el-descriptions-item>
          <el-descriptions-item label="发布时间">
            {{ lockData.addTime }}
          </el-descriptions-item>
          <el-descriptions-item label="级别">
            {{ lockData.msgLevelTxt }}
          </el-descriptions-item>
          <el-descriptions-item label="公告类型">
            {{ lockData.msgTypeTxt }}
          </el-descriptions-item>
          <el-descriptions-item label="收件人">
            <i v-for="(item, index) in lockData.user" :key="index">
              {{
                item.userName + (lockData.user.length == index + 1 ? '' : ',')
              }}
            </i>
          </el-descriptions-item>
          <el-descriptions-item label="内容" :span="2">
            <div class="wrap-html" v-html="lockData.content"></div>
          </el-descriptions-item>
        </el-descriptions>
      </div>
    </div>
  </div>
</template>

<script>
import lyHeader from './../../layout/header/index.vue'
import Base64 from 'base-64'
export default {
  components: { lyHeader },
  data() {
    return {
      userInfo: {
        userName: this.$crypto.decrypt(
          Base64.decode(JSON.parse(sessionStorage.userInfo).userName)
        ),
        workPost: JSON.parse(sessionStorage.userInfo).workPost,
        lastLoginTime: JSON.parse(sessionStorage.userInfo).lastLoginTime,
      },
      lockData: {},
    }
  },
  created() {
    if (this.$route.query.id) {
      this.itemList()
    }
  },
  methods: {
    go() {
      //返回
      const url = this.$route.query.type ? '/home/index' : '/home/backlog'
      this.$router.push(url)
    },
    itemList() {
      // 获取详情
      this.$axios
        .get('/admin/messsage/readMyMessage?id=' + this.$route.query.id)
        .then((data) => {
          this.lockData = {}
          if (data.code == 200) {
            this.lockData = data.data
          } else {
            this.$message.error(data.msg)
          }
        })
    },
  },
}
</script>
<style scoped>
.home-header {
  padding-bottom: 20px;
}
</style>
